<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Jetson Inference: Memory Management</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="NVLogo_2D.jpg"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Jetson Inference
   </div>
   <div id="projectbrief">DNN Vision Library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__cudaMemory.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Memory Management<div class="ingroups"><a class="el" href="group__util.html">Utilities Library (jetson-utils)</a> &raquo; <a class="el" href="group__cuda.html">CUDA</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>Allocation of CUDA mapped zero-copy memory.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga08121b272362dcd6f06d71a5a660c1e9"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cudaMemory.html#ga08121b272362dcd6f06d71a5a660c1e9">cudaAllocMapped</a> (void **cpuPtr, void **gpuPtr, size_t size)</td></tr>
<tr class="memdesc:ga08121b272362dcd6f06d71a5a660c1e9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocate ZeroCopy mapped memory, shared between CUDA and CPU.  <a href="#ga08121b272362dcd6f06d71a5a660c1e9">More...</a><br /></td></tr>
<tr class="separator:ga08121b272362dcd6f06d71a5a660c1e9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaebaf526c95c617fba65d29943b88333d"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cudaMemory.html#gaebaf526c95c617fba65d29943b88333d">cudaAllocMapped</a> (void **ptr, size_t size)</td></tr>
<tr class="memdesc:gaebaf526c95c617fba65d29943b88333d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocate ZeroCopy mapped memory, shared between CUDA and CPU.  <a href="#gaebaf526c95c617fba65d29943b88333d">More...</a><br /></td></tr>
<tr class="separator:gaebaf526c95c617fba65d29943b88333d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa52f87e1fd1acb41b7fecd08e698d652"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cudaMemory.html#gaa52f87e1fd1acb41b7fecd08e698d652">cudaAllocMapped</a> (void **ptr, size_t width, size_t height, <a class="el" href="group__imageFormat.html#ga931c48e08f361637d093355d64583406">imageFormat</a> format)</td></tr>
<tr class="memdesc:gaa52f87e1fd1acb41b7fecd08e698d652"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocate ZeroCopy mapped memory, shared between CUDA and CPU.  <a href="#gaa52f87e1fd1acb41b7fecd08e698d652">More...</a><br /></td></tr>
<tr class="separator:gaa52f87e1fd1acb41b7fecd08e698d652"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga8a2888fa56181613241c517a156351d9"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__cudaMemory.html#ga8a2888fa56181613241c517a156351d9">cudaAllocMapped</a> (void **ptr, const int2 &amp;dims, <a class="el" href="group__imageFormat.html#ga931c48e08f361637d093355d64583406">imageFormat</a> format)</td></tr>
<tr class="memdesc:ga8a2888fa56181613241c517a156351d9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocate ZeroCopy mapped memory, shared between CUDA and CPU.  <a href="#ga8a2888fa56181613241c517a156351d9">More...</a><br /></td></tr>
<tr class="separator:ga8a2888fa56181613241c517a156351d9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaab0dab07a3448b93f7022ce304a47a8b"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:gaab0dab07a3448b93f7022ce304a47a8b"><td class="memTemplItemLeft" align="right" valign="top">bool&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__cudaMemory.html#gaab0dab07a3448b93f7022ce304a47a8b">cudaAllocMapped</a> (T **ptr, size_t width, size_t height)</td></tr>
<tr class="memdesc:gaab0dab07a3448b93f7022ce304a47a8b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocate ZeroCopy mapped memory, shared between CUDA and CPU.  <a href="#gaab0dab07a3448b93f7022ce304a47a8b">More...</a><br /></td></tr>
<tr class="separator:gaab0dab07a3448b93f7022ce304a47a8b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae2c4c5bb3fe6978716bb275b8f863eee"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:gae2c4c5bb3fe6978716bb275b8f863eee"><td class="memTemplItemLeft" align="right" valign="top">bool&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__cudaMemory.html#gae2c4c5bb3fe6978716bb275b8f863eee">cudaAllocMapped</a> (T **ptr, const int2 &amp;dims)</td></tr>
<tr class="memdesc:gae2c4c5bb3fe6978716bb275b8f863eee"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocate ZeroCopy mapped memory, shared between CUDA and CPU.  <a href="#gae2c4c5bb3fe6978716bb275b8f863eee">More...</a><br /></td></tr>
<tr class="separator:gae2c4c5bb3fe6978716bb275b8f863eee"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>Allocation of CUDA mapped zero-copy memory. </p>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga08121b272362dcd6f06d71a5a660c1e9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga08121b272362dcd6f06d71a5a660c1e9">&#9670;&nbsp;</a></span>cudaAllocMapped() <span class="overload">[1/6]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool cudaAllocMapped </td>
          <td>(</td>
          <td class="paramtype">void **&#160;</td>
          <td class="paramname"><em>cpuPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void **&#160;</td>
          <td class="paramname"><em>gpuPtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Allocate ZeroCopy mapped memory, shared between CUDA and CPU. </p>
<dl class="section note"><dt>Note</dt><dd>although two pointers are returned, one for CPU and GPU, they both resolve to the same physical memory.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">cpuPtr</td><td>Returned CPU pointer to the shared memory. </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">gpuPtr</td><td>Returned GPU pointer to the shared memory. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">size</td><td>Size (in bytes) of the shared memory to allocate.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>true</code> if the allocation succeeded, <code>false</code> otherwise. </dd></dl>

</div>
</div>
<a id="gaebaf526c95c617fba65d29943b88333d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaebaf526c95c617fba65d29943b88333d">&#9670;&nbsp;</a></span>cudaAllocMapped() <span class="overload">[2/6]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool cudaAllocMapped </td>
          <td>(</td>
          <td class="paramtype">void **&#160;</td>
          <td class="paramname"><em>ptr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>size</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Allocate ZeroCopy mapped memory, shared between CUDA and CPU. </p>
<dl class="section note"><dt>Note</dt><dd>this overload of cudaAllocMapped returns one pointer, assumes that the CPU and GPU addresses will match (as is the case with any recent CUDA version).</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">ptr</td><td>Returned pointer to the shared CPU/GPU memory. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">size</td><td>Size (in bytes) of the shared memory to allocate.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>true</code> if the allocation succeeded, <code>false</code> otherwise. </dd></dl>

</div>
</div>
<a id="gaa52f87e1fd1acb41b7fecd08e698d652"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa52f87e1fd1acb41b7fecd08e698d652">&#9670;&nbsp;</a></span>cudaAllocMapped() <span class="overload">[3/6]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool cudaAllocMapped </td>
          <td>(</td>
          <td class="paramtype">void **&#160;</td>
          <td class="paramname"><em>ptr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>width</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>height</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__imageFormat.html#ga931c48e08f361637d093355d64583406">imageFormat</a>&#160;</td>
          <td class="paramname"><em>format</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Allocate ZeroCopy mapped memory, shared between CUDA and CPU. </p>
<p>This overload is for allocating images from an imageFormat type and the image dimensions. The overall size of the allocation will be calculated with the <a class="el" href="group__imageFormat.html#gae8779cdbde4c4543a26a736ef7222fae" title="Compute the size of an image (in bytes) ">imageFormatSize()</a> function.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">ptr</td><td>Returned pointer to the shared CPU/GPU memory. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">width</td><td>Width (in pixels) to allocate. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">height</td><td>Height (in pixels) to allocate. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">format</td><td>Format of the image.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>true</code> if the allocation succeeded, <code>false</code> otherwise. </dd></dl>

</div>
</div>
<a id="ga8a2888fa56181613241c517a156351d9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga8a2888fa56181613241c517a156351d9">&#9670;&nbsp;</a></span>cudaAllocMapped() <span class="overload">[4/6]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool cudaAllocMapped </td>
          <td>(</td>
          <td class="paramtype">void **&#160;</td>
          <td class="paramname"><em>ptr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const int2 &amp;&#160;</td>
          <td class="paramname"><em>dims</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__imageFormat.html#ga931c48e08f361637d093355d64583406">imageFormat</a>&#160;</td>
          <td class="paramname"><em>format</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Allocate ZeroCopy mapped memory, shared between CUDA and CPU. </p>
<p>This overload is for allocating images from an imageFormat type and the image dimensions. The overall size of the allocation will be calculated with the <a class="el" href="group__imageFormat.html#gae8779cdbde4c4543a26a736ef7222fae" title="Compute the size of an image (in bytes) ">imageFormatSize()</a> function.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">ptr</td><td>Returned pointer to the shared CPU/GPU memory. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dims</td><td><code>int2</code> vector where <code>width=dims.x</code> and <code>height=dims.y</code> </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">format</td><td>Format of the image.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>true</code> if the allocation succeeded, <code>false</code> otherwise. </dd></dl>

</div>
</div>
<a id="gaab0dab07a3448b93f7022ce304a47a8b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaab0dab07a3448b93f7022ce304a47a8b">&#9670;&nbsp;</a></span>cudaAllocMapped() <span class="overload">[5/6]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool cudaAllocMapped </td>
          <td>(</td>
          <td class="paramtype">T **&#160;</td>
          <td class="paramname"><em>ptr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>width</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>height</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Allocate ZeroCopy mapped memory, shared between CUDA and CPU. </p>
<p>This is a templated version for allocating images from vector types like uchar3, uchar4, float3, float4, ect. The overall size of the allocation will be calculated as <code>width * height * sizeof(T)</code>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">ptr</td><td>Returned pointer to the shared CPU/GPU memory. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">width</td><td>Width (in pixels) to allocate. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">height</td><td>Height (in pixels) to allocate.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>true</code> if the allocation succeeded, <code>false</code> otherwise. </dd></dl>

</div>
</div>
<a id="gae2c4c5bb3fe6978716bb275b8f863eee"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae2c4c5bb3fe6978716bb275b8f863eee">&#9670;&nbsp;</a></span>cudaAllocMapped() <span class="overload">[6/6]</span></h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool cudaAllocMapped </td>
          <td>(</td>
          <td class="paramtype">T **&#160;</td>
          <td class="paramname"><em>ptr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const int2 &amp;&#160;</td>
          <td class="paramname"><em>dims</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Allocate ZeroCopy mapped memory, shared between CUDA and CPU. </p>
<p>This is a templated version for allocating images from vector types like uchar3, uchar4, float3, float4, ect. The overall size of the allocation will be calculated as <code>dims.x * dims.y * sizeof(T)</code>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">ptr</td><td>Returned pointer to the shared CPU/GPU memory. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">dims</td><td><code>int2</code> vector where <code>width=dims.x</code> and <code>height=dims.y</code></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd><code>true</code> if the allocation succeeded, <code>false</code> otherwise. </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Tue Jul 14 2020 21:59:34 for Jetson Inference by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
